/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.carrito.jdbc.dao;

import com.carrito.jsf.persistence.Alumno;
import java.util.List;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

/**
 *
 * @author oscarc
 */
public class ImpAlumno extends HibernateDaoSupport implements IfaceAlumno {

    @Override
    public void insert(Alumno obj) {
        getHibernateTemplate().save(obj);
    }

    @Override
    public void delete(Alumno obj) {
        List<Alumno> alumnos = getHibernateTemplate().find("FROM Alumno AS o WHERE o.codigo = ?",obj.getCodigo());
        
        obj = alumnos.get(0);
        getHibernateTemplate().delete(obj);

    }

    @Override
    public void update(Alumno obj) {
        getHibernateTemplate().merge(obj);

    }

    @Override
    public List<Alumno> getAll() {
        return getHibernateTemplate().find("FROM Alumno");

    }
}
